package models

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

type Rule struct {
	gorm.Model
	ImageUrl  string  `json:"image_url" gorm:"type:varchar(255);column:image_url"`
	Title     string  `json:"title" gorm:"type:varchar(50);comment:标题"`
	Introduce string  `json:"introduce" gorm:"type:varchar(100);comment:详情"`
	Moment    string  `json:"moment" gorm:"type:varchar(30);comment:过期时间"`
	Price     float64 `gorm:"type:decimal(10,2);comment:优惠价格"`
}

func (r *Rule) RuleList() (info []Rule, err error) {
	return info, mysql.WithMysql(func(db *gorm.DB) error {
		return db.Table("rules").Find(&info).Error
	})
}
